define(["jquery","layuiall","jqform","helper"],function ($,layui,jqform,helper) {
    var laydate = layui.laydate;
    controller = {
        index:function () {
            var form = layui.form;
            form.on('switch(status)', function(data){
                var status = 0;
                if(data.elem.checked){
                    status = 1
                }
                $.ajax({
                    type:'post',
                    data:{
                        id:data.value,
                        status:status
                    },
                    url:$(data.elem).attr("data-url"),
                    success:function (res) {
                        layer.msg(res.msg)
                    }
                })
            });
            jqform.delete()
            form.on('checkbox(select-all)', function(data){

                if(data.elem.checked==true){
                    $("input[name='idList[]']").prop('checked',true)
                }else {
                    $("input[name='idList[]']").prop('checked',false)
                }
                form.render('checkbox');
            });
        },
        addslide:function () {
            laydate.render({
                elem: '#datetime',
                type:'datetime',
                range: "~",
            });
            jqform.init();
            $("#test1").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/system/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#app-photo").find("input[name='photo']").val(file[0].filepath);
                        $("#app-photo").find("img").attr("src",file[0].preview_url);
                        localStorage.removeItem("upload");
                    }
                });
            });
        },
        editslide:function () {
            laydate.render({
                elem: '#datetime',
                type:'datetime',
                range: "~",
            });
            jqform.init();
            $("#test1").click(function () {
                uploadFiles({
                    url: '/admin/webupload/webuploader/multi/1/filetype/image/app/system/tab/local',
                    file:function (res) {
                        var file = JSON.parse(res);
                        $("#app-photo").find("input[name='photo']").val(file[0].filepath);
                        $("#app-photo").find("img").attr("src",file[0].preview_url);
                        localStorage.removeItem("upload");
                    }
                });
            });
        }
    }
    return controller;
})